package org.xtext.context.aware.serializer;

import com.google.inject.Inject;
import com.google.inject.Provider;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor;
import org.eclipse.xtext.serializer.acceptor.SequenceFeeder;
import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider;
import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;
import org.xtext.context.aware.eventX.ActionType;
import org.xtext.context.aware.eventX.CloseBy;
import org.xtext.context.aware.eventX.ConditionalEvent;
import org.xtext.context.aware.eventX.ContextAwareModel;
import org.xtext.context.aware.eventX.Date;
import org.xtext.context.aware.eventX.Event;
import org.xtext.context.aware.eventX.EventAttributes;
import org.xtext.context.aware.eventX.EventXPackage;
import org.xtext.context.aware.eventX.Notification;
import org.xtext.context.aware.eventX.OpenBrowser;
import org.xtext.context.aware.eventX.ParallelAction;
import org.xtext.context.aware.eventX.PlayMedia;
import org.xtext.context.aware.eventX.PlaySound;
import org.xtext.context.aware.eventX.RoomEvent;
import org.xtext.context.aware.eventX.SequentialAction;
import org.xtext.context.aware.eventX.SimpleAction;
import org.xtext.context.aware.eventX.Time;
import org.xtext.context.aware.eventX.TimeTable;
import org.xtext.context.aware.eventX.TransitionArea;
import org.xtext.context.aware.eventX.Vibrate;
import org.xtext.context.aware.eventX.WeekDayTime;
import org.xtext.context.aware.services.EventXGrammarAccess;

@SuppressWarnings("all")
public class EventXSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private EventXGrammarAccess grammarAccess;
	
	public void createSequence(EObject context, EObject semanticObject) {
		if(semanticObject.eClass().getEPackage() == EventXPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) {
			case EventXPackage.ACTION_TYPE:
				if(context == grammarAccess.getActionTypeRule()) {
					sequence_ActionType(context, (ActionType) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.CLOSE_BY:
				if(context == grammarAccess.getBasicEventRule() ||
				   context == grammarAccess.getCloseByRule() ||
				   context == grammarAccess.getEventTypeRule()) {
					sequence_CloseBy(context, (CloseBy) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.CONDITIONAL_EVENT:
				if(context == grammarAccess.getConditionalEventRule() ||
				   context == grammarAccess.getEventTypeRule()) {
					sequence_ConditionalEvent(context, (ConditionalEvent) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.CONTEXT_AWARE_MODEL:
				if(context == grammarAccess.getContextAwareModelRule()) {
					sequence_ContextAwareModel(context, (ContextAwareModel) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.DATE:
				if(context == grammarAccess.getDateRule()) {
					sequence_Date(context, (Date) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.EVENT:
				if(context == grammarAccess.getElementRule() ||
				   context == grammarAccess.getEventRule()) {
					sequence_Event(context, (Event) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.EVENT_ATTRIBUTES:
				if(context == grammarAccess.getEventAttributesRule()) {
					sequence_EventAttributes(context, (EventAttributes) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.NOTIFICATION:
				if(context == grammarAccess.getNotificationRule()) {
					sequence_Notification(context, (Notification) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.OPEN_BROWSER:
				if(context == grammarAccess.getOpenBrowserRule()) {
					sequence_OpenBrowser(context, (OpenBrowser) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.PARALLEL_ACTION:
				if(context == grammarAccess.getActionRule() ||
				   context == grammarAccess.getElementRule() ||
				   context == grammarAccess.getParallelActionRule()) {
					sequence_ParallelAction(context, (ParallelAction) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.PLAY_MEDIA:
				if(context == grammarAccess.getPlayMediaRule()) {
					sequence_PlayMedia(context, (PlayMedia) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.PLAY_SOUND:
				if(context == grammarAccess.getPlaySoundRule()) {
					sequence_PlaySound(context, (PlaySound) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.ROOM_EVENT:
				if(context == grammarAccess.getBasicEventRule() ||
				   context == grammarAccess.getEventTypeRule() ||
				   context == grammarAccess.getRoomEventRule()) {
					sequence_RoomEvent(context, (RoomEvent) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.SEQUENTIAL_ACTION:
				if(context == grammarAccess.getActionRule() ||
				   context == grammarAccess.getElementRule() ||
				   context == grammarAccess.getSequentialActionRule()) {
					sequence_SequentialAction(context, (SequentialAction) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.SIMPLE_ACTION:
				if(context == grammarAccess.getActionRule() ||
				   context == grammarAccess.getElementRule() ||
				   context == grammarAccess.getSimpleActionRule()) {
					sequence_SimpleAction(context, (SimpleAction) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.TIME:
				if(context == grammarAccess.getTimeRule()) {
					sequence_Time(context, (Time) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.TIME_TABLE:
				if(context == grammarAccess.getElementRule() ||
				   context == grammarAccess.getTimeTableRule()) {
					sequence_TimeTable(context, (TimeTable) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.TRANSITION_AREA:
				if(context == grammarAccess.getBasicEventRule() ||
				   context == grammarAccess.getEventTypeRule() ||
				   context == grammarAccess.getTransitionAreaRule()) {
					sequence_TransitionArea(context, (TransitionArea) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.VIBRATE:
				if(context == grammarAccess.getVibrateRule()) {
					sequence_Vibrate(context, (Vibrate) semanticObject); 
					return; 
				}
				else break;
			case EventXPackage.WEEK_DAY_TIME:
				if(context == grammarAccess.getWeekDayTimeRule()) {
					sequence_WeekDayTime(context, (WeekDayTime) semanticObject); 
					return; 
				}
				else break;
			}
		if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Constraint:
	 *     (actionType=Vibrate | actionType=PlaySound | actionType=PlayMedia | actionType=Notification | actionType=OpenBrowser)
	 */
	protected void sequence_ActionType(EObject context, ActionType semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID attributes+=EventAttributes*)
	 */
	protected void sequence_CloseBy(EObject context, CloseBy semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (basic=BasicEvent (logic='or' | logic='and' | logic='andnot') nested=EventType)
	 */
	protected void sequence_ConditionalEvent(EObject context, ConditionalEvent semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     elements+=Element*
	 */
	protected void sequence_ContextAwareModel(EObject context, ContextAwareModel semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (year=INT month=INT day=INT)
	 */
	protected void sequence_Date(EObject context, Date semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, EventXPackage.Literals.DATE__YEAR) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EventXPackage.Literals.DATE__YEAR));
			if(transientValues.isValueTransient(semanticObject, EventXPackage.Literals.DATE__MONTH) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EventXPackage.Literals.DATE__MONTH));
			if(transientValues.isValueTransient(semanticObject, EventXPackage.Literals.DATE__DAY) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EventXPackage.Literals.DATE__DAY));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getDateAccess().getYearINTTerminalRuleCall_0_0(), semanticObject.getYear());
		feeder.accept(grammarAccess.getDateAccess().getMonthINTTerminalRuleCall_2_0(), semanticObject.getMonth());
		feeder.accept(grammarAccess.getDateAccess().getDayINTTerminalRuleCall_4_0(), semanticObject.getDay());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     ((hasRadius?='radius=' radius=INT) | (hasTime?='time=' time=[TimeTable|ID]) | (hasTolerance?='tolerance=' tolerance=INT))
	 */
	protected void sequence_EventAttributes(EObject context, EventAttributes semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID (hasAction?='-> action' actionType=ActionType)? events+=EventType*)
	 */
	protected void sequence_Event(EObject context, Event semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (notification='notification' message=STRING)
	 */
	protected void sequence_Notification(EObject context, Notification semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, EventXPackage.Literals.NOTIFICATION__NOTIFICATION) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EventXPackage.Literals.NOTIFICATION__NOTIFICATION));
			if(transientValues.isValueTransient(semanticObject, EventXPackage.Literals.NOTIFICATION__MESSAGE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EventXPackage.Literals.NOTIFICATION__MESSAGE));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getNotificationAccess().getNotificationNotificationKeyword_0_0(), semanticObject.getNotification());
		feeder.accept(grammarAccess.getNotificationAccess().getMessageSTRINGTerminalRuleCall_1_0(), semanticObject.getMessage());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (openBrowser='openbrowser' url=STRING)
	 */
	protected void sequence_OpenBrowser(EObject context, OpenBrowser semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, EventXPackage.Literals.OPEN_BROWSER__OPEN_BROWSER) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EventXPackage.Literals.OPEN_BROWSER__OPEN_BROWSER));
			if(transientValues.isValueTransient(semanticObject, EventXPackage.Literals.OPEN_BROWSER__URL) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EventXPackage.Literals.OPEN_BROWSER__URL));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getOpenBrowserAccess().getOpenBrowserOpenbrowserKeyword_0_0(), semanticObject.getOpenBrowser());
		feeder.accept(grammarAccess.getOpenBrowserAccess().getUrlSTRINGTerminalRuleCall_1_0(), semanticObject.getUrl());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID? event=[Event|ID] actionType+=ActionType*)
	 */
	protected void sequence_ParallelAction(EObject context, ParallelAction semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (playMedia='media' mediaFileName=STRING)
	 */
	protected void sequence_PlayMedia(EObject context, PlayMedia semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, EventXPackage.Literals.PLAY_MEDIA__PLAY_MEDIA) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EventXPackage.Literals.PLAY_MEDIA__PLAY_MEDIA));
			if(transientValues.isValueTransient(semanticObject, EventXPackage.Literals.PLAY_MEDIA__MEDIA_FILE_NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EventXPackage.Literals.PLAY_MEDIA__MEDIA_FILE_NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getPlayMediaAccess().getPlayMediaMediaKeyword_0_0(), semanticObject.getPlayMedia());
		feeder.accept(grammarAccess.getPlayMediaAccess().getMediaFileNameSTRINGTerminalRuleCall_1_0(), semanticObject.getMediaFileName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (playSound='sound' soundFileName=STRING)
	 */
	protected void sequence_PlaySound(EObject context, PlaySound semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, EventXPackage.Literals.PLAY_SOUND__PLAY_SOUND) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EventXPackage.Literals.PLAY_SOUND__PLAY_SOUND));
			if(transientValues.isValueTransient(semanticObject, EventXPackage.Literals.PLAY_SOUND__SOUND_FILE_NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EventXPackage.Literals.PLAY_SOUND__SOUND_FILE_NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getPlaySoundAccess().getPlaySoundSoundKeyword_0_0(), semanticObject.getPlaySound());
		feeder.accept(grammarAccess.getPlaySoundAccess().getSoundFileNameSTRINGTerminalRuleCall_1_0(), semanticObject.getSoundFileName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     ((eventType='entering' | eventType='leaving') name=ID (hasTime?='time=' time=[TimeTable|ID])?)
	 */
	protected void sequence_RoomEvent(EObject context, RoomEvent semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID? event=[Event|ID] actionType+=ActionType*)
	 */
	protected void sequence_SequentialAction(EObject context, SequentialAction semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID? event=[Event|ID] actionType=ActionType)
	 */
	protected void sequence_SimpleAction(EObject context, SimpleAction semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID dateFrom=Date? dateTo=Date? weekdays+=WeekDayTime*)
	 */
	protected void sequence_TimeTable(EObject context, TimeTable semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (hours=INT minutes=INT)
	 */
	protected void sequence_Time(EObject context, Time semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, EventXPackage.Literals.TIME__HOURS) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EventXPackage.Literals.TIME__HOURS));
			if(transientValues.isValueTransient(semanticObject, EventXPackage.Literals.TIME__MINUTES) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EventXPackage.Literals.TIME__MINUTES));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getTimeAccess().getHoursINTTerminalRuleCall_0_0(), semanticObject.getHours());
		feeder.accept(grammarAccess.getTimeAccess().getMinutesINTTerminalRuleCall_2_0(), semanticObject.getMinutes());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (from=ID attributesFrom+=EventAttributes* to=ID attributesTo+=EventAttributes*)
	 */
	protected void sequence_TransitionArea(EObject context, TransitionArea semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (vibrate='vibrate' (hasDuration?='duration=' (duration='short' | duration='long'))?)
	 */
	protected void sequence_Vibrate(EObject context, Vibrate semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (
	 *         (
	 *             day='monday' | 
	 *             day='tuesday' | 
	 *             day='wednesday' | 
	 *             day='thursday' | 
	 *             day='friday' | 
	 *             day='saturday' | 
	 *             day='sunday'
	 *         ) 
	 *         timeFrom=Time 
	 *         timeTo=Time
	 *     )
	 */
	protected void sequence_WeekDayTime(EObject context, WeekDayTime semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
}
